package com.example.wangfanwangluo.wangfanboss;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import static com.example.wangfanwangluo.wangfanboss.R.id.back_forget3;

public class Forget3 extends AppCompatActivity {
    private TextView backbtn;
    private Typeface iconfont;
    private EditText pwet;
    private EditText agpwet;
    private Button nextbtn;
    private RelativeLayout nextbtnbagr; //下一步按钮的背景布局

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_forget3);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ActionBar actionbar = getSupportActionBar();
        if (actionbar != null){
            actionbar.hide();
        }
        initViews();
    }
    public void initViews(){
        //设置iconfont字体
        iconfont = Typeface.createFromAsset(getAssets(), "iconfont/iconfont.ttf");
        backbtn = (TextView)findViewById(back_forget3);
        backbtn.setTypeface(iconfont);
        pwet = (EditText)findViewById(R.id.pw_forget3);
        agpwet = (EditText)findViewById(R.id.pwagain_forget3);
        nextbtn = (Button)findViewById(R.id.nextbtn_forget3);
        backbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //返回上一页
               finish();
            }
        });
        //新密码输入监听,一旦输入，更改nextbtn的颜色

        nextbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //校验2次密码是否一致
                String pwstr = pwet.getText().toString();
                String agpwstr = agpwet.getText().toString();
                Log.d("忘记密码3",pwstr);
                Log.d("忘记密码3",agpwstr);
                if (!pwet.getText().toString().equals(agpwet.getText().toString())) {
                    Toast.makeText(Forget3.this,"2次密码不一致",Toast.LENGTH_SHORT).show();
                    return;
                }
                //进入主页面
                Intent intent = new Intent(Forget3.this,Login.class);
                startActivity(intent);
            }
        });



    }
}
